<template>
  <div class="app-container fullscreen">
    <div class="headBar">
      <img src="@/assets/images/njHead.png" />
      <div class="headName">
        智能农场设备总览
      </div>
    </div>
    <div class="container">
      <div id="left">
        <div class="box">
          <img src="@/assets/images/njTip.png" class="njTip" />
          <div class="title">
            <img src="@/assets/images/njIcon.png" class="njIcon" />
            <div class="titleName">气象报告</div>
          </div>
          <div class="content table">
            <tableView :location="location" />
          </div>
        </div>
        <div class="box">
          <img src="@/assets/images/njTip.png" class="njTip" />
          <div class="title">
            <img src="@/assets/images/njIcon.png" class="njIcon" />
            <div class="titleName">预警/消息</div>
          </div>
          <div class="content">
            <iframe width="100%" height="100%" :src="waring" />
          </div>
        </div>
      </div>
      <div id="center">
        <div class="box">
          <img src="@/assets/images/njTip.png" class="njTip" />
          <div class="title">
            <img src="@/assets/images/njIcon.png" class="njIcon" />
            <div class="titleName">设备概览</div>
          </div>
          <div class="content" style="display:flex; justify-content: space-around;">
            <peiCharts width="400px" />
            <pei-charts-2 width="400px" />
          </div>
        </div>
        <div class="box">
          <img src="@/assets/images/njTip.png" class="njTip" />
          <div class="title">
            <img src="@/assets/images/njIcon.png" class="njIcon" />
            <div class="titleName">终端在线率</div>
          </div>
          <div class="content">
            <div class="rate">
              <div>
                <img :src="require('./rate.png')" />
                <div>
                  <div>终端在线率</div>
                  <div>50%</div>
                </div>
              </div>
              <div>较差</div>
            </div>
            <lineCharts height="360px" width="900px"></lineCharts>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="box">
          <img src="@/assets/images/njTip.png" class="njTip" />
          <div class="title">
            <img src="@/assets/images/njIcon.png" class="njIcon" />
            <div class="titleName">设备在线情况</div>
          </div>
          <div class="content">
            <div class="list">
              <div v-for="(light, i) of lightList" :key="i" class="itemCard">
                <div class="name">{{ light.name }}</div>
                <div class="warper">
                  <div>
                    <img :src="require('./light.png')" />
                    <div>
                      <div>开灯</div>
                      <div>5</div>
                    </div>
                  </div>
                  <div>
                    <img :src="require('./closeLight.png')" />
                    <div>
                      <div>关灯</div>
                      <div>5</div>
                    </div>
                  </div>
                  <div>
                    <img :src="require('./offline.png')" />
                    <div>
                      <div>离线</div>
                      <div>5</div>
                    </div>
                  </div>
                  <div>
                    <img :src="require('./waring.png')" />
                    <div>
                      <div>异常</div>
                      <div>5</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { waring } from '@/api/weather'
import Iframe from '@/components/Iframe'
import MapGis from '@/components/MapGis'
import lineCharts from './lineCharts.vue'
import peiCharts from './peiCharts.vue'
import PeiCharts2 from './peiCharts2.vue'
import tableView from './table.vue'

export default {
  components: {
    MapGis,
    peiCharts,
    lineCharts,
    tableView,
    Iframe,
    PeiCharts2
  },
  data() {
    return {
      waring: undefined,
      location: '120.55,31.22',
      lightList: [{ name: '杀虫灯(10)' }, { name: '智能虫情测报灯 (5)' }, { name: '横网式杀虫灯 (10)' }]
    }
  },
  created() {
    this.getWaring()
  },
  methods: {
    getWaring() {
      return waring(this.location).then(r => (this.waring = r.data.fxLink))
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  //width: 1920px;
  //height: 1080px;
  width: 100%;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  background: #010429;
}
.container {
  width: calc(100% - 40px);
  height: calc(100% - 144px);
  display: flex;
  margin: 0 20px;
}
.box {
  width: 100%;
  border: 4px solid #121c3b;
  padding: 16px;
  border-radius: 16px;
  box-sizing: border-box;
  position: relative;
  background: #0a182d;
  margin-bottom: 20px;
  .njTip {
    position: absolute;
    right: 20px;
    top: -10px;
    width: 60px;
  }
  .title {
    display: flex;
    align-items: center;
    color: #2cedf1;
    font-size: 24px;
    position: relative;
    font-weight: bold;
    .njIcon {
      width: 40px;
      margin-right: 20px;
    }
  }
}
.headBar {
  width: 100%;
  height: 144px;
  color: #fff;
  position: relative;
  .headName {
    text-align: center;
    position: absolute;
    font-size: 40px;
    left: 50%;
    top: 30%;
    transform: translate(-50%, 0);
  }
}
#left {
  width: 25%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .table {
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 10px 0;
    box-sizing: border-box;
  }
  .box:last-child {
    flex: 1;
    padding-bottom: 50px;
    .content {
      height: 100%;
      margin: 10px 0;
    }
  }
}
#center {
  width: 50%;
  margin: 0 10px;
  .map {
    width: 100%;
    height: 720px;
  }
  .bottom {
    margin-top: 32px;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .rate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 50px;
    margin-top: 20px;

    > div {
      &:first-child {
        display: flex;
        align-items: center;
        color: white;
        font-size: 20px;
        text-align: center;
        img {
          width: 60px;
          margin-right: 20px;
        }
        div div:last-child {
          color: #a8dffa;
        }
      }
      &:last-child {
        color: red;
        border: 1px solid white;
        border-radius: 60px;
        width: 60px;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
}
.right {
  width: 25%;
  height: 100%;

  .title {
    margin-bottom: 40px;
  }

  .itemCard {
    margin: 0 auto;
    margin-bottom: 20px;
    color: #fff;
    font-size: 16px;
    padding: 10px;
    box-sizing: border-box;
    .name {
      width: 100%;
      height: 40px;
      line-height: 40px;
      font-size: 22px;
      text-indent: 44px;
      background: url(./card-title-bg.png) left center / cover;
    }
    .warper {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      border: 2px solid #2e3a66;
      padding: 12px 36px;
      margin-top: 12px;
      img {
        width: 60px;
        margin-right: 20px;
      }
      > div {
        display: flex;
        font-size: 24px;
        text-align: center;
        margin-bottom: 30px;
        &:nth-child(n + 3) {
          margin-bottom: 0;
        }
        > div > div:last-child {
          color: #a8dffa;
        }
      }
    }
  }
}
</style>
